import pyautogui
import time
import threading
from PIL import ImageGrab

import pydirectinput

def sleep(t):
    time.sleep(t)

sleep(2)
pydirectinput.keyDown("w")
sleep(4.5)
pydirectinput.keyUp("w")